import {
    fetchEquipments,
    addNewEquipment,
    editEquipment,
    deleteEquipment
  } from "@/api/pandora"

  export default {
    namespaced: true,
      actions: {
        async fetchEquipments(context, payload){
            let {marketId, type, page, perPage} = payload
            try {
                const { data } = await fetchEquipments(marketId, type, page, perPage)
                return data
            }catch (error){
                console.log("store-modules-position-index.js-fetchEquipments", error)
            }
        },

        async addNewEquipment(context, payload) {
          let {marketId, posId, equipmentType, equipmentName, equipmentMac, type} = payload
          try {
              const { data } = await addNewEquipment(marketId, posId, equipmentType, equipmentName, equipmentMac, type)
              return data
          }catch (error){
              console.log("store-modules-position-index.js-addNewFlow", error)
          }
        },

        async editEquipment(context, payload) {
          let {equipmentId, marketId, posId, equipmentType, equipmentName, equipmentMac, type} = payload
          try {
              const { data } = await editEquipment(equipmentId, marketId, posId, equipmentType, equipmentName, equipmentMac, type)
              return data
          }catch (error){
              console.log("store-modules-position-index.js-editEquipment", error)
          }
        },

        async deleteEquipment(context, payload) {
          let {equipmentId, marketId, type} = payload
          try {
              const { data } = await deleteEquipment(equipmentId, marketId, type)
              return data
          }catch (error){
              console.log("store-modules-position-index.js-deleteEquipment", error)
          }
        },
      }
  }